const app = getApp()

let zrEndX = 50;
let zrEndY = 50;
let startX = 0;
let startY = 0;
let offsetX = 0;
let offsetY = 0;

Page({
  data: {
    avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/sRz7ibxGs2GgrdicIuffuFOQ6KHePbOicJUe78xbXHBgeIOHqTu0RpquzgSOUkpdXREO8p4FdZNZ8Ig9zXuQyPpLQ/132",
    degNum: 0,
    scaleNum: 1
  },

  onLoad: function () {

  },


  xzStart(e) {
    const {
      pageX,
      pageY
    } = e.changedTouches[0];

    startX = pageX - zrEndX;
    startY = pageY - zrEndY;

    console.log('起始值', startX, startY)
  },

  xzMove(e) {
    const {
      pageX,
      pageY
    } = e.changedTouches[0];

    //当前位置进行移动
    offsetX = pageX - startX;
    offsetY = pageY - startY;

    //根据x,y 确定旋转角度
    let degNum = Number((offsetY - offsetX).toFixed(2));
    let scaleNum = Number(((offsetX + offsetY) / 90).toFixed(2));

    console.log(`旋转角度：${degNum}, 缩放大小：${scaleNum}`)

    this.setData({
      degNum,
      scaleNum
    })

  },

  xzEnd(e) {
    zrEndX = offsetX || startX;
    zrEndY = offsetY || startY;
  }


})